<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <!--0:引入 vue.js-->
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
    <!--0:引入 axios.js-->
    <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
    
</head>
<body>   
    <div id ="app3">        
            用户 <input type="text" v-model = "uname"><br> 
            密码 <input type="text" v-model = "upwd"><br>
            邮箱 <input type="text" v-model="email"><br>
            电话 <input type="text" v-model="phone"><br>
            <button  @click.prevent = "register">注册</button>           
        </div>
    </div>
    <script>
        //配合axios调用时的基本URL
        //axios.defaults.baseURL="http://115.159.160.93:8080";
        axios.defaults.baseURL="http://localhost:5050";
        var vm = new Vue({
            el:"#app3",
            data:{
                isLogin:false,
                uname:"dingding",
                upwd:"123456",
                email:"",
                phone:"",    
            },
            methods: {              

                register(){                    
                    //注册
                    let uname =  this.uname;
                    let upwd = this.upwd; 
                    let email = this.email;
                    let phone = this.phone;                   
                    axios.post("/user/register",{uname,upwd,email,phone}).then(result=>{
                        console.log(result.data);
                        if(result.data.code==200){
                            console.log(`用户"${uname}"注册成功`);                            
                        }else{
                            console.log(`用户"${uname}"注册不成功`);  
                        }
                    })
                }
    
            }
        })
    </script>
    
</body>
</html>